HomeAbout MeContact

Accessing SharePoint REST API using Postman

Published in SharePoint
October 16, 2022
2 min read
Accessing SharePoint REST API using Postman

Table Of Contents

01
Requirements
02
Registering an app in SharePoint
03
Giving permission to the app
04
Getting the "Tenant Id"
05
Accessing SharePoint from Post machine

Do you want to try connecting through SharePoint using Postman? Here is the step-by-step tutorial how to connect Postman with REST API

Requirements

  • Postman installed in your machine(https://www.postman.com/)
  • SharePoint

Registering an app in SharePoint

Go to <sitecollectionurl>/_layouts/15/appregnew.aspx to login your app in SharePoint. And following the following steps:

Registering a new app to my SharePoint site
Registering a new app to my SharePoint site

  1. Click on “Generate” button for the “Client Id”. Save the value you will get in a notepad
  2. Click on “Generate” button for the “Client Secret”. Save the value you will get in a notepad
  3. For the Title, kindly type in the name of your App. Ex: “Postman Local Access”
  4. For App Domain, just type in www.google.com.
  5. Redirect Url “https://localhost/”
  6. Press “Create” to continue registering your app.

It should look like this after filling up
It should look like this after filling up

You should be redirected to a success page

Success message showing that your app is now created(registered)
Success message showing that your app is now created(registered)

Giving permission to the app

After registering, we need to define what kind of permission we want to give the app.

Go to <sitecollectionurl>/_layouts/15/appinv.aspx

Note: if you want to give permission to your whole tenant, you need to use the following url <SP admin url>/_layouts/15/appinv.aspx

This is the page for giving app permission to certain site collection
This is the page for giving app permission to certain site collection

This is the page for giving app permission to the whole tenant
This is the page for giving app permission to the whole tenant

For the “App Id,” try entering in the “Client ID” that we generated earlier, then press the “Lookup” button.

While for the “Permission Request XML” typer the following. Make you replace your Scope

<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://<<tenanturl>>/content/sitecollection/web" Right="FullControl" />
</AppPermissionRequests>

It should look like this
It should look like this

Getting the “Tenant Id”

If you know your Tenant ID, feel free to skip this part. But here is the URL to get your Tenant ID

Go to <sitecollectionurl>/_layouts/15/appprincipals.aspx

Your Tenant ID will be the GUID after the ”@” character

Tenant ID
Tenant ID

Accessing SharePoint from Post machine

We need to generate first the access token of SharePoint before we can start using SharePoint REST API. Open your postman and do the following.

URL: https://accounts.accesscontrol.windows.net/<Tenant ID>/tokens/OAuth/2/
Method: Post
Header: {
"grant_type": "client_credentials",
"client id": <Client ID>@<Tenant ID>
"client secret": <Client Secret>"
"resource": "00000003-0000-0ff1-ce00-000000000000/<sharepoint root site>.sharepoint.com@<Tenant ID>"
}

After hitting Send in Postman, you should receive an “access_token” reply

After Send, you should be getting the following response
After Send, you should be getting the following response

Copy the whole “Access token,” and feel free to use it to access your SharePoint REST API using Postman. As an example, I am going to get all available Lists on my site

URL: https://blahblah.sharepoint.com/sites/BillyPeraltaSite/_api/web/lists
Method: GET
Header: {
"Authorization": "Bearer <access_token>",
"Accept": "application/json;odata=verbose"
"Content-Type": "application/json;odata=verbose"
}

I got a 200 response and I am now able to get all my Lists in my Site in Postman
I got a 200 response and I am now able to get all my Lists in my Site in Postman


Tags

O365M365SharePoint OnlinePostman

Share


Previous Article
Creating a Ordering System in PowerApps

Related Posts

Using PowerShell to Query all Power Automate Workflow that uses SharePoint or Onedrive actions
Using PowerShell to Query all Power Automate Workflow that uses SharePoint or Onedrive actions
August 27, 2022
1 min

Quick Links

About MeContact Me

Social Media